package com.spice.service.entity.pojo;

import com.baomidou.mybatisplus.annotation.TableName;
import com.spice.common.constant.PermissionConstant;
import com.spice.common.model.BaseEntity;
import com.spice.service.entity.form.EditDocumentForm;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.File;

@Data
//@JsonInclude(JsonInclude.Include.NON_NULL)
@NoArgsConstructor
@AllArgsConstructor
@TableName("document_info")
@ApiModel(description = "文档信息")
public class DocumentInfo extends FileInfo {
    @ApiModelProperty(value = "文档类型", example = PermissionConstant.SCIENTIFIC_RESEARCH_DOC)
    private String type;

    @ApiModelProperty(value = "细节描述", example = "这篇文档是关于辣椒的")
    private String details;



    public DocumentInfo setFileInfo(FileInfo fileInfo) {
        super.setDownloadUrl(fileInfo.getDownloadUrl());
        super.setLocalFileName(fileInfo.getLocalFileName());
        super.setOriginalFileName(fileInfo.getOriginalFileName());
        return this;
    }

    public DocumentInfo setDocumentInfo(EditDocumentForm editDocumentForm) {
        this.setType(editDocumentForm.getType());
        this.setDetails(editDocumentForm.getDetails());
        return this;
    }

    public boolean checkType() {
        return PermissionConstant.LEARNING_MATERIALS_DOC.equals(type)
                || PermissionConstant.SCIENTIFIC_RESEARCH_DOC.equals(type);
    }

}
